<template>
  <div class="t-select">
    <el-select
      ref="select"
      v-model="moduleValue"
      size="small"
      placeholder=""
      multiple
      :disabled="disabled"
      @change="handleChange"
    >
      <el-option
        v-for="item in options"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      >
      </el-option>
    </el-select>
  </div>
</template>
<script>
export default {
  name: "TMultipleSelect",
  props: {
    value: {
      type: [Array, null],
      default: () => [],
      require: true,
    },
    options: {
      type: Array,
      default: () => [],
    },
    disabled: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {};
  },
  computed: {
    moduleValue: {
      get() {
        return this.value || [];
      },
      set(val) {
        this.$emit("input", val || []);
      },
    },
  },
  methods: {
    focus() {
      const select = this.$refs.select;
      if (select) {
        select.focus();
      }
    },
    handleChange(value) {
      this.$emit("change", value || []);
    },
  },
};
</script>
<style lang="scss" scoped></style>
